home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
v9n19.arc
/
REPL.BAT
< prev
next >
Wrap
DOS Batch File
|
1990-10-13
|
2KB
|
47 lines
[[REPL.BAT]]
@ECHO OFF
IF '%3'=='' GOTO explain
ECHO Now checking for valid parameters . . .
ECHO %2 | FIND "%1" > XXXXXXXX.TMP
REM Only if %2 contained %1 will the tempfile be
REM non-empty. DOS won't copy an empty file. So
REM if the second tempfile exists, %2 DID contain %1.
COPY XXXXXXXX.TMP YYYYYYYY.TMP > NUL
DEL XXXXXXXX.TMP > NUL
IF EXIST YYYYYYYY.TMP GOTO BadParams
ECHO Replacing "%1" with "%2" in files matching:
ECHO %3 %4 %5 %6 %7 %8 %9
:--------------------------------------------------
ECHO Now creating DEBUG script. . .
ECHO NTEMPEDLN.SCR > TEMPDEBG.SCR
ECHO E CS:100 '1R%1' 1A '%2' 0D 0A 'E' 0D 0A 1A >> TEMPDEBG.SCR
ECHO RCX >> TEMPDEBG.SCR
ECHO 40 >> TEMPDEBG.SCR
ECHO W >> TEMPDEBG.SCR
ECHO Q >> TEMPDEBG.SCR
:--------------------------------------------------
ECHO Now creating EDLIN script . . .
DEBUG < TEMPDEBG.SCR > NUL
DEL TEMPDEBG.SCR
ECHO Replacing "%1" with "%2" in files matching: > REPL.LOG
ECHO %3 %4 %5 %6 %7 %8 %9 >> REPL.LOG
:--------------------------------------------------
ECHO Now performing replacement . . .
FOR %%f IN (%3 %4 %5 %6 %7 %8 %9) DO EDLIN %%f < tempedln.scr >> REPL.LOG
DEL TEMPEDLN.SCR
ECHO To see a log of the work REPL.BAT did, read the file REPL.LOG
GOTO end
:BadParams
DEL YYYYYYYY.TMP > NUL
ECHO Unfortunately, the string "%2" _contains_
ECHO the string "%1". REPL.BAT can't handle that.
GOTO end
:Explain
ECHO SYNTAX: "REPLACE findstr replacestr filespec [filespec...]
ECHO This batch program will search files matching up to 7
ECHO file specifications and replace all occurrences of the
ECHO "find string" with the "replace string" in each file.
:end